
import './index.scss'
import { useNavigate, useLocation } from 'react-router-dom'
import { orderDetail } from '../../api/perOrder'


const Pay = () => {

    const location = useLocation()
    console.log('11', location);
    // const { allFee, addressInfo } = location.data.result

    const { orderId, qrcode, allFee } = location.state
    // const timeRef = useRef(60)
    // const pageRef = useRef(1)

    const timer = setInterval(() => {
        // timeRef.current--/

        orderDetail({ orderId }).then(res => {

            if (res.data.result.orderStatus === '01') {
                clearInterval(timer)
                navigate('/advance')
            }
            else {
                console.log('您还没有支付');
            }
        })
    }, 7000)


    const navigate = useNavigate()

    const goOrder = () => {
        navigate('/cart')
    }
    return <>
        <div className="pay">
            <div className="Cashier">
                <span className='iconfont icon-fanhuidingbu' onClick={goOrder}></span>  <div>收银台</div>
            </div>
            <div className='pay-money'>
                <div className='pay-sum'>￥{allFee}.00</div>
                <div className='pay-time'>支付剩余时间</div>
            </div>
            <div className='pay-adress'>
                <div>联系地址：*****</div>
                <div>
                    竖**,
                    152****9273
                </div>
            </div>
            <div className='pay-fn'>微信扫码支付</div>
            <div className='pay-select'>
                <img src={qrcode} alt={orderId} />

            </div>
        </div>
    </>
}
export default Pay